// 后台路由

const express = require('express');
const router = express.Router();



//引入后台控制器
const adminController = require('../controllers/adminController');

router.get('/',adminController.index);

router.get('/login',adminController.loginPage);

router.post('/login',adminController.login);

//------------------------用户管理------------------
//显示用户所有数据
router.get('/user',adminController.listUser)

//新增:第一步
router.get('/add',adminController.addPage)
//新增：第二步
router.post('/add',adminController.addUser)

//编辑第一步
router.get('/edit/:id',adminController.getOneUser)

//编辑第二步
router.post('/edit',adminController.editUser)

//删除
router.get('/delete/:id',adminController.deleteUser)

//查询
router.post('/search',adminController.searchUser)


// ---------------菜单管理-------------------
/**
 * @api {get} /menu 菜单管理界面
 * @apiDescription 
 * @apiName menu
 * @apiGroup menu
 * @apiSampleRequest http://localhost:3000/api/menu
 * @apiVersion 1.0.0
 */
router.get('/menu',adminController.menu);
/**
 * @api {get} /menuEdit 菜单编辑界面
 * @apiDescription 
 * @apiName menuEdit
 * @apiGroup menu
 * @apiParam {string} menuId 分类Id
 * @apiSampleRequest http://localhost:3000/api/menuEdit
 * @apiVersion 1.0.0
 */
router.get('/menuEdit/:id',adminController.menuEdit);


// -------------文章分类模块-------------------
/**
 * @api {get} /classify 文章分类界面
 * @apiDescription 
 * @apiName classify
 * @apiGroup classify

 * @apiSampleRequest http://localhost:3000/api/classify
 * @apiVersion 1.0.0
 */
router.get('/classify',adminController.classify);
/**
 * @api {get} /classEdit 文章编辑界面
 * @apiDescription 
 * @apiName classEdit
 * @apiGroup classify
* @apiParam {string} classId 分类Id
 * @apiSampleRequest http://localhost:3000/api/classEdit
 * @apiVersion 1.0.0
 */
router.get('/classEdit/:id',adminController.classifyEdit);


// -----------------------------文章管理------------------
/**
 * @api {get} / 文章管理首页
 * @apiDescription 文章管理首页
 * @apiName /artical
 * @apiGroup artical
 * @apiSampleRequest http://localhost:3000/api/artical
 * @apiVersion 1.0.0
 */
router.get('/artical',adminController.getAllArtical);
/**
 * @api {get} / 文章管理添加页面
 * @apiDescription 文章管理添加页面
 * @apiName /addArtical
 * @apiGroup artical
 * @apiSampleRequest http://localhost:3000/api/addArtical
 * @apiVersion 1.0.0
 */
router.get('/addArtical',adminController.addArticalPage);
/**
 * @api {post} /login 添加文章
 * @apiDescription 添加文章
 * @apiName addArtical
 * @apiGroup artical
 * @apiParam {string} classId 文章分类ID
 * @apiParam {string} className 文章分类
 * @apiSampleRequest http://localhost:3000/api/addArtical
 * @apiVersion 1.0.0
 */
router.post('/addArtical',adminController.addArtical);
/**
 * @api {get} / 文章管理删除页面
 * @apiDescription 文章管理删除页面
 * @apiName /deleteArtical
 * @apiGroup artical
 * @apiSampleRequest http://localhost:3000/api/deleteArtical/:id
 * @apiVersion 1.0.0
 */
router.get('/deleteArtical/:id',adminController.deleteArtical);
/**
 * @api {get} / 文章管理编辑页面
 * @apiDescription 文章管理编辑页面
 * @apiName /editArtical
 * @apiGroup artical
 * @apiSampleRequest http://localhost:3000/api/editArtical/:id
 * @apiVersion 1.0.0
 */
router.get('/editArtical/:id',adminController.editArticalPage);
/**
 * @api {post} /login 编辑文章
 * @apiDescription 编辑文章
 * @apiName editArtical
 * @apiGroup artical
 * @apiParam {string} classId 文章分类ID
 * @apiParam {string} articalName 文章名称
 * @apiParam {string} content 文章内容
 * @apiSampleRequest http://localhost:3000/api/addArtical
 * @apiVersion 1.0.0
 */
router.post('/editArtical',adminController.editArtical);




module.exports = router;